/* UINTUTIL.H - header file for shared UINTUTIL.C functions */

/* By:   S.C. Molitor (smolitor@bme.jhu.edu)
   Date: February 8, 1999 */


// structure for complex numbers

typedef struct complex_struct {
	double		real;
	double		imag;
} complex;

#define REAL(x)		(x.real)
#define IMAG(x)		(x.imag)


// CALCDIMSTRIDE - calculate index increment along a specified dimension

int CalcDimStride(const int	*sizeX,
				  int		dimX);

// COORDINCREMENT - increment N-D coordinate with dimension skip

void CoordIncrement(const int	*sizeX,
					int			*coordX,
					int			ndimsX,
					int			dimskip);

// COORDINDEX - convert N-D matrix coordinate into linear array index

int CoordIndex(const int	*sizeX,
			   const int	*coordX,
			   int			ndimsX);

// CREATELOGICAL - create logical output array

mxArray	*CreateLogical(const mxArray	*A,
					   const mxArray	*B,
					   mxClassID		classC);


// CREATENUMERIC - create numeric output array

mxArray	*CreateNumeric(const mxArray	*A,
					   const mxArray	*B,
					   mxClassID		classC);


// GETCOMPLEX - recast complex array element value as DOUBLE

complex GetComplex(const mxArray	*input,
				   bool				isComplex,
				   mxClassID		classID,
				   int				index);


// GETDOUBLE - recast real array element value as DOUBLE

double GetDouble(const mxArray		*input,
				 mxClassID			classID,
				 int				index);


// GETFIRSTNSDIM - obtain first non-singleton dimension

int GetFirstNSDim(const mxArray	*prhs[],
				  int			nrhs,
				  int			irhs,
				  const int		*sizeX,
				  int			ndimsX);


// ISFIRSTNSDIM - indicate first non-singleton dimension

bool IsFirstNSDim(const int	*sizeX,
				  int		dimX);


// VALIDATEINPUTS - check for valid syntax

void ValidateInputs(int				nlhs,
					int				nrhs,
					const mxArray	*prhs[],
					int				minrhs,
					int				maxrhs,
					int				maxlhs);
